package com.javatimes.test.action;

import java.util.List;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;

import com.javatimes.test.po.Dept;
import com.javatimes.test.service.IDeptService;
import com.javatimes.test.util.JsonUtils;
import com.opensymphony.xwork2.ActionSupport;

@Result(name="success",location="/index.jsp",type="dispatcher")
public class DeptAction extends ActionSupport{
	
	private static final long serialVersionUID = 1L;
	
	@Autowired
	IDeptService ideptService;
	
	List<Dept> list;

	int id;
	
	@Action(value="tt")
	public void queryAll(){
		
		//json ssh list<dept>  转成jsonarray list<map> jackson.jar
//		JsonUtils.jsonExcludes("emps");
		JsonUtils.toJsonToWeb(ideptService.queryDept(id));
		this.setList(ideptService.queryAll());
	}
	
	public String queryAll1(){
		System.out.println("------------");
		JsonUtils.toJsonToWeb(ideptService.queryAll());
		
		this.setList(ideptService.queryAll());
		return SUCCESS;
	}
	
	public List<Dept> getList() {
		return list;
	}

	public void setList(List<Dept> list) {
		this.list = list;
	}

	public void setId(int id) {
		this.id = id;
	}

	
}
